Setting system up to your region:
ln -s /usr/share/zoneinfo/New_York /etc/localtime
- Links timezone filedate - Print date in specified format
date +%j
= Day of the yeardate +%H
= Hour of day
date +%H%J
= Hour+Day of Yeartimedatectl - Set system date and time information
timedatectl status
= Show current settingstzselect - Select timezone
dpkg-reconfigure tzdata - Configure timezone data on Debian systems
localectl - Configure system locale and keyboard layout settings
Interacting with system through a visual design element
Types of GUIs:
Display Server
X Window System also known as X11 or X
Tunneling any port over SSH
ssh -L 4043:localhost:22 user@host
Reverse Tunnel masqueraded as SSL:
ssh -2NR 999:public_ip:443
Services: Software that responds to requests from other programs to provide specialized functionality.
Daemons: Services running in background that don't require human interaction. Lie dormant until called upon.
Loading of OS and components. Accomplished with init daemon
Run Levels: /etc/rc#.d
1 = Single-user
2 = Multi-user without networking
3 = Multi-user with networking
4 = Not used
5 = Loads desktop environment with networking
6 = Reboot
chkconfig --level <service> on/off
systemd
/etc/systemd/system/ = Links/copies
/lib/systemd/system/ = Actual files being linked
systemd:
systemd-anaylze blame
- Identifty processes slowing down a system
systemctl: Instructs systemd what to do
systemctl list-unit-files
systemctl mask <unit>
- Redirect unit to /dev/null; making the target unable to activatesystemctl isolate graphical.target
- Bring up GUIsystemctl set-default graphical.target
- Sets the GUI to launch at bootNICE value
top
- Displays NI value
nice wireshark
- Start wireshark with nice value of 10 (lower priority)
nice -15 wireshark
- Start wireshark with nice value of -15 (higher priority)
renice -n 15 <pid>
- Set priority on a running process
renice -n 15 $(pgrep wireshark)
- Grabs the pid of wireshark and sets nice value to 15
ctrl+z
= pause program/command
jobs
= list current programs/commands
bg <job#>
= background job
fg <job#>
= foreground job
nohup <command>
= start command seperate from terminal control
kill -9 <pid>
pkill <name of process>
killall <name of process>
List all open files
lsof
lsof +d /dir/here
- List open files in a specific directory
How long a system's been running
uptime
System usage reports
sar
Memory Statistics
free -h
Create 1GB of Swap Space
Creates 1G filew ith zeros
dd if=/dev/zero of=/swapfile bs=1M count=1024
mkswap /swapfile
swapon /swapfile
swapoff /swapfile
Change date/timezone
timedatectl list-timezones | grep \<country\>
timedatectl set-timezone \<timezone\>
Change locale / keyboard mapping
localectl status
localectl list-keymaps
localectl list-locale
localectl set-locale "LANG=en_US.utf8"
localectl set-keymap us
Setting up GUIs
From CLI: systemctl isolate graphical.target
Configuring target files
/usr/lib/systemd/system/<target.files>
- Location of target files
systemctl --type=service
= View current target's services
systemctl isolate multi-user.target
= Switch to CLI only
systemctl set-default graphical.target
= From CLI set GUI to be default environment.
systemctl status sshd.service
- List SSH status
systemctl disable firewalld.service
- Will disable firewall on startup but not effect the current running status
Process Management
top
+ M = Organize by memory usage
top
+ P = Organize by CPU usage
lsof
= List files and who opened them
lsof -u student01
= See files opened by student01
systemd-analyze
= Analyze the time it took to start the kernel, initrd, and userspace
systemd-analyze blame
= Display slowest loaded processes
top
+ r = Renice
Dispaly CPU info
less /proc/cpuinfo
Display system information
sar -u
sar 2 6
= gather information every two seconds for 6 queries
sar -S
= Gather swap space information
less /proc/meminfo
= Display memory information
free -h
= Display memory usage in human-readable format
vmstat -d 5 3
= Display virtual memory statistics per storage device